<!--
* description: 意向客户
* author: zouzx
* createdDate: 2019-10-24
-->
<template>
  <section class="carTypeConfig">
    <el-dialog
      v-dialogDrag
      title="意向客户"
      :visible.sync="curPopupsVisible"
      width="1000px"
      center
      @close="sendCode"
      :close-on-click-modal="false"
      :append-to-body="true"
    >
      <dialogHeader slot="title" :title="'意向客户'" :styleType="$store.state.app.dialogType"></dialogHeader>
      <one-table-template
        ref="multipleTable"
        :dynamicButtons="tableButtons"
        :dynamicComponents="tableComponents"
        :dynamicApiConfig="apiConfig"
        :dynamicTableCols="tableCols"
        :dynamicFormFields="formField"
        :dynamicIsShowSelect="isMul"
      />
    </el-dialog>
  </section>
</template>
<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import { valueObjectMixins } from "@/components/mixins/valueObjectMixins";
import { crmApis } from "@/api/apiList/crm";
import OneTableTemplate from "@/components/crm/commonComponents/crmPopupsOneTable";
export default {
  // 组件混入对象：{data[listQuery] methods[queryTable]}
  mixins: [oneTableWithViewTemplateMixins, valueObjectMixins],
  components: {
    OneTableTemplate,
    dialogHeader: () => import("@/components/dialogHeader") //弹窗标题
  },
  data() {
    return {
      // 网格查询API配置对象
      apiConfig: crmApis.mdmDlrCustIntentQueryList,
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey1",
          type: "primary",
          size: "small",
          clickEvent: () => this.queryTable(1),
          text: "查询",
          position: "top"
        },
        {
          compKey: "btnKey2",
          type: "primary",
          size: "small",
          clickEvent: () => this.sendCode("caEmpId", "custName"),
          text: "确认",
          position: "bottom"
        },
        {
          compKey: "btnKey3",
          type: "",
          size: "small",
          clickEvent: () => this.reset(),
          text: "重置",
          position: "top"
        }
      ],
      // 动态组件-查询条件
      tableComponents: [
        // 显示组件
        // {
        //   compKey: "compKey1",
        //   labelName: "网点",
        //   codeField: "dlrId",
        //   component: () =>
        //     import("@/components/crm/crmEjectWindows/crmChangeDlr/index"),
        //   type: "propus",
        //   isMust: false,
        //   isMul: false
        // },
        {
          compKey: "compKey2",
          labelName: "销售顾问",
          codeField: "caEmpId",
          component: () =>
            import("@/components/crm/crmEjectWindows/crmSalesConsultant/index"),
          type: "propus",
          isMust: false,
          isMul: false,
          disabled:false,
        },
        {
          compKey: "compKey3",
          labelName: "客户类型",
          codeField: "custClassCode",
          lookuptype: "DB0006",
          component: () => import("@/components/org/LookupValue"),
          type: "dropdownList",
          isMust: false,
          isMul: false
        },
        {
          compKey: "compKey4",
          labelName: "客户名称",
          codeField: "custName",
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey5",
          labelName: "电话",
          codeField: "phone",
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey6",
          labelName: "是否大客户",
          codeField: "isVip",
          lookuptype: "DB0064",
          component: () => import("@/components/org/LookupValue"),
          type: "dropdownList",
          isMust: false,
          isMul: false
        },
        {
          compKey: "compKey7",
          labelName: "建档日期",
          codeField: "startDate,endDate",
          component: () => import("@/components/crm/Time/crmdtDatePicker"),
          type: "inputText",
          isMust: false
        }
      ],
      // 动态生成网格列
      tableCols: [
        {
          prop: "dlrShortName",
          label: "网点",
          width: 150,
          align: "center",
          fixed: true
        },
        {
          prop: "custName",
          label: "客户名称",
          width: 100,
          align: "center",
          fixed: true
        },
        {
          prop: "phone",
          label: "电话",
          width: 120,
          align: "center",
          fixed: true
        },
        {
          prop: "caEmpName",
          label: "销售顾问",
          width: 100,
          align: "center"
        },
        {
          prop: "custTypeName",
          label: "客户类型",
          width: 90,
          align: "center"
        },
        {
          prop: "isVipName",
          label: "是否大客户",
          width: 90,
          align: "center"
        },
        {
          prop: "intentLevel",
          label: "意向级别",
          width: 90,
          align: "center"
        },
        { prop: "carBrandCn", label: "意向品牌", width: 130, align: "center" },
        {
          prop: "carSeriesCn",
          label: "意向车系",
          width: 150,
          align: "center"
        },
        {
          prop: "intentCarType",
          label: "意向车型",
          width: 200,
          align: "center",
          hidden:true
        },
        {
          prop: "intentCarTypeCn",
          label: "意向车型",
          width: 200,
          align: "center"
        },
        // {
        //   prop: "customerSourseName",
        //   label: "客户来源",
        //   width: 120,
        //   align: "center"
        // },
        { prop: "infoSourceName", label: "信息来源", width: 200, align: "center" },
        {
          prop: "createdDate",
          label: "建档日期",
          width: 150,
          align: "center"
        },
        { prop: "addDetail", label: "详细地址", width: 170, align: "center" },
        {
          prop: "intentCustNo",
          label: "意向客户ID",
          width: null,
          align: "center",
          hidden: true
        },
        {
          prop: "dlrId",
          label: "网点ID",
          width: null,
          align: "center",
          hidden: true
        },
        {
          prop: "caEmpId",
          label: "销售顾问ID",
          width: null,
          align: "center",
          hidden: true
        },
        {
          prop: "custClassCode",
          label: "客户类型编码",
          width: null,
          align: "center",
          hidden: true
        },
        {
          prop: "isVip",
          label: "是否大客户",
          width: null,
          align: "center",
          hidden: true
        }
      ],
      //表单查询数据（查询条件）
      formField: {
        oemCode: "1",
        groupCode: "1",
        custName: "",
        phone: "",
        custClassCode: "",
        isVip: "",
        caEmpId: "",
        dlrId: this.$store.getters.orgInfo.DLR_ID,
        startDate: "",
        endDate: "",
        unInclueIntentLevelList: ["F", "L", "R", "T", "M", "D"]
      },
      //双击事件
      handleTableRowData:{
        value:"caEmpId",
        text:"custName"
      }
    };
  },
  mounted(){
    if(this.$store.getters.orgInfo.POS_CODE.indexOf('VE0003')>-1){
      this.tableComponents[0].disabled=false;
    }else{
      this.tableComponents[0].disabled=true;
      this.formField.caEmpId=this.$store.getters.orgInfo.EMP_ID;
    }
  },
};
</script>
